#include <iostream>
using namespace std;

/*
    友元类：把整个类声明成另一个类的友元

    3.特点
        第一个：友元不能继承，A是B的友元类，但是A的子类并不是B的友元类
        第二个：友元是单向的，A是B的友元，但是不能反过来说
        第三个：友元不能传递，A是B的友元，B是C的友元，不能得出结论A是C的友元
        友元类很单纯
     缺点
        破坏了类的封装性

*/

class AliPay
{
public:
    AliPay(string account, string passwd, double money)
    {
        this->account = account;
        this->passwd = passwd;
        this->money = money;
    }

private:
    friend class Person;
    string account;
    string passwd;
    double money;
};

class Person
{
public:
    Person(string name)
    {
        this->name = name;
    }

    void showAliPay(AliPay &alipay)
    {
        cout << "name: " << name << endl;
        cout << "account: " << alipay.account << endl;
        cout << "passwd: " << alipay.passwd << endl;
        cout << "money: " << alipay.money << endl;
    }

private:
    string name;
};

int main()
{
    AliPay alipay("123456", "123456", 1000);
    Person person("Tom");
    person.showAliPay(alipay);

    return 0;
}